package cn.rulian.base.auth.bo;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import cn.rulian.base.common.bo.BaseSetBo;
import cn.rulian.base.common.dto.CommonDto;

import com.fasterxml.jackson.annotation.JsonFormat;


/** 
 * Description: 资源
 */

@Entity
@Table(name = "base_auth_resource")
public class Resource extends BaseSetBo{
	
	@ManyToOne
	@JoinColumn(name = "father_id")
	private Resource father; //父资源
	
	@Column(length = 50)
	private String name; //资源名称
	
	@Column(length = 50)
	private String authCode; //权限码（不可重复，与业务系统中的配置相对应）

	@ManyToOne
	@JoinColumn(name = "resourceType_id")
	private ResourceType resourceType; //资源类型
	
	private Boolean enabled; //是否可用
	
	private Boolean locked; //是否锁定。锁定后不允许删除，防止误操作。
	
	@Column(length = 20)
	private String menuState; //菜单状态，'open' 或 'closed'。
	
	private Integer orderNum; //排序号
	
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") 
	private Date addTime; //增加时间
	
	@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinTable(name="base_auth_role_resource",
			joinColumns=@JoinColumn(name="resourceId", referencedColumnName="id"), 
			inverseJoinColumns=@JoinColumn(name="roleId", referencedColumnName="id"))
	private List<Role> roleList;

	@Column(length = 200)
	private String url; //地址
	
	@Column(length = 50)
	private String iconCls; //图标
	
	@Column(length = 20)
	private String systemNo; //系统编号，0 是公共编码（用于支持多系统，2018-10-19）
	
	private Boolean openWin; //是否新窗口打开
	
	@Transient
	private Long _parentId; //树网络展示时，确定父子关系

	@Transient
	private String state; //展示时是否打开，值来源于 menuState
	
	@Transient
	private List<CommonDto> son; //角色权限设置：用于保存下级按钮

	@Transient
	private boolean checked;//角色权限设置：用于保存是否被选中
	

	public Resource getFather()
	{
		return father;
	}

	public void setFather(Resource father)
	{
		this.father = father;
	}

	public String getAuthCode()
	{
		return authCode;
	}

	public void setAuthCode(String authCode)
	{
		this.authCode = authCode;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public ResourceType getResourceType()
	{
		return resourceType;
	}

	public void setResourceType(ResourceType resourceType)
	{
		this.resourceType = resourceType;
	}

	public Boolean getEnabled()
	{
		return enabled;
	}

	public void setEnabled(Boolean enabled)
	{
		this.enabled = enabled;
	}

	public Boolean getLocked()
	{
		return locked;
	}

	public void setLocked(Boolean locked)
	{
		this.locked = locked;
	}

	public Integer getOrderNum()
	{
		return orderNum;
	}

	public void setOrderNum(Integer orderNum)
	{
		this.orderNum = orderNum;
	}

	public Date getAddTime()
	{
		return addTime;
	}

	public void setAddTime(Date addTime)
	{
		this.addTime = addTime;
	}

	public List<Role> getRoleList()
	{
		return roleList;
	}

	public void setRoleList(List<Role> roleList)
	{
		this.roleList = roleList;
	}

	public String getUrl()
	{
		return url;
	}

	public void setUrl(String url)
	{
		this.url = url;
	}

	public String getIconCls()
	{
		return iconCls;
	}

	public void setIconCls(String iconCls)
	{
		this.iconCls = iconCls;
	}

	public Long get_parentId()
	{
		return _parentId;
	}

	public void set_parentId(Long _parentId)
	{
		this._parentId = _parentId;
	}

	public String getMenuState()
	{
		return menuState;
	}

	public void setMenuState(String menuState)
	{
		this.menuState = menuState;
	}

	public String getState()
	{
		return state;
	}

	public void setState(String state)
	{
		this.state = state;
	}

	public List<CommonDto> getSon()
	{
		return son;
	}

	public void setSon(List<CommonDto> son)
	{
		this.son = son;
	}


	public boolean isChecked()
	{
		return checked;
	}

	public void setChecked(boolean checked)
	{
		this.checked = checked;
	}

	public String getSystemNo() {
		return systemNo;
	}

	public void setSystemNo(String systemNo) {
		this.systemNo = systemNo;
	}

	public Boolean getOpenWin() {
		return openWin;
	}

	public void setOpenWin(Boolean openWin) {
		this.openWin = openWin;
	}
	

}